home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / utils / rtrac800 / scn2sff.lst < prev    next >
Encoding:
File List  |  1992-09-08  |  18.3 KB  |  567 lines

  1.  
  2.                                                       SCN2SFF(1G)
  3.  
  4. NAME
  5.      scn2sff - format conversion program
  6.  
  7. SYNOPSIS
  8.      scn2sff [options] {SCNfile|-} [>SFFfile]
  9.  
  10. AUTHOR
  11.      Antonio Costa, INESC-Norte, 1991 1992
  12.  
  13. DESCRIPTION
  14.      scn2sff command performs conversion between a text format
  15.      (SCN) suitable for scene descriptions to another more simple
  16.      text format (SFF) that is accepted by the rtrace ray-tracer
  17.      program.  The SCN text file describes objects, lights, sur-
  18.      face definitions, textures, etc.  The scene format is
  19.      described bellow.
  20.  
  21. OPTIONS
  22.      [C]
  23.      The parameter C tells the program to preprocess the input
  24.      file through the UNIX standard preprocessor (/usr/lib/cpp
  25.      with option -P).
  26.  
  27.      [M]
  28.      The parameter M tells the program to preprocess the input
  29.      file through the M4 preprocessor (/usr/bin/m4).
  30.  
  31.      [P"preprocessor command"]
  32.      The parameter P tells the program to preprocess the input
  33.      file through the command described (for example,
  34.      P"/usr/lib/cpp -P -Dabc").
  35.  
  36. RESTRICTIONS
  37.      None for the moment.
  38.  
  39. BUGS
  40.      No bugs known.  They have to be hidden deep somewhere, as
  41.      usual.
  42.  
  43. DESCRIPTION
  44.      Comments start with % ; or # characters and continue to the
  45.      end of the line (so there are no nested comments).
  46.  
  47.      The commands are processed from the start of the scene, and
  48.      some have a global effect until they are changed or the
  49.      scene is complete. Such commands are refraction, surface,
  50.      transformations and textures; as commands can be nested by
  51.      grouping, any command defined inside a group is removed when
  52.      that group is finished.
  53.  
  54.      Example:
  55.  
  56.      surface matte white        % current surface is matte white
  57.      refraction 1.1             % current refraction index
  58.      transform rotate x 15      % transformation
  59.      group                      % start of a group of commands
  60.        surface matte red        % new current surface
  61.        transform scale 2        % transformation
  62.        sphere 0 0 0 1           % sphere object
  63.      ungroup                    % end of group
  64.      % back to matte white surface, refraction 1.1
  65.      % scale transformation is removed
  66.  
  67.                          ENTITIES
  68.  
  69.      The main entities are:
  70.  
  71.      integer - it can be a simple number, an integer expression
  72.      enclosed in parenthesis or the int function applied to any
  73.      real expression.
  74.  
  75.      real - a number, a function or an expression enclosed in
  76.      parenthesis.
  77.  
  78.      color - a triplet of RGB real values between 0 and 1 (in
  79.      certain cases, it is allowed to be greater than 1 or nega-
  80.      tive; called color_extended) or a name (like red, blue,
  81.      etc).
  82.  
  83.      point - a triplet of XYZ values (numbers, functions or
  84.      expressions).
  85.  
  86.      vector - similar to point, but the 3 components cannot be
  87.      simultaneously equal to 0.
  88.  
  89.      filename - a set of characters with no blanks between.
  90.  
  91.      expression - anything enclosed in parenthesis. Operators are
  92.      +, -, *, /, ^ (exponentiation) and | (remainder).
  93.  
  94.      function - there are many functions available: int sin cos
  95.      tan asin acos atan sqrt rtod dtor exp log abs max min. There
  96.      also some functions that operate with vectors and return a
  97.      number (dotvector) and some that return a vector or point
  98.      (normvector addvector diffvector scalevector crossvector).
  99.      There is also an operator mono that converts from a value to
  100.      3 identical values (good for specifying monochromatic
  101.      colors).
  102.  
  103.                          GENERAL COMMANDS
  104.  
  105.      The main commands are:
  106.  
  107.      eye (from) point - default {5,0,0}.
  108.  
  109.      look (at) point - default {0,0,0}.
  110.  
  111.      up vector - default {0,1,0}.
  112.  
  113.      angle (fov) horizontal [vertical] - half aperture view in
  114.      degrees (default 22.5 degrees).
  115.  
  116.      background color - the color of the background, at infinite
  117.      distance (default light_sky_blue).
  118.  
  119.      ambient color - the diffuse light that illuminates the whole
  120.      scene (default is {0.1,0.1,0.1}).
  121.  
  122.      refraction (ior) index - default is 1.
  123.  
  124.      group ... ungroup - anything enclosed is only defined inside
  125.      the block, ie, it does not apply outside.
  126.  
  127.                          LIGHT COMMANDS
  128.  
  129.      The commands for definition of light sources are:
  130.  
  131.      light point point [color_extended] - default color for
  132.      lights is white.
  133.  
  134.      light directional vector [color].
  135.  
  136.      light spot point vector color_extended [angle [factor]] -
  137.      the light illuminates inside a cone defined by the angle
  138.      (default 45 degrees) and the transition can be sharp if fac-
  139.      tor is near 1 or smooth if factor >> 1 (default 1).
  140.  
  141.      light extended point color_extended radius samples - a
  142.      spherical light (it is sampled by samples^2 rays).
  143.  
  144.                          SURFACE COMMANDS
  145.  
  146.      The commands for definition of surfaces are:
  147.  
  148.      surface color [diffusion specularity phong metalness [tran-
  149.      sparency]] - phong and metalness are values, the others are
  150.      colors (defaults {0.9,0.9,0.9} {0.1,0.1,0.1} 3 0
  151.      {0.1,0.1,0.1} or transparency only {0,0,0}).
  152.  
  153.      surface strauss color smoothness metalness [transparency] -
  154.      all colors (default transparency is {0,0,0}).
  155.  
  156.      surface matte color - all diffuse surface.
  157.  
  158.      surface plastic color smoothness phong - surface with big
  159.      diffusion, small specularity and small phong factor.
  160.  
  161.      surface metal color smoothness phong - surface with small
  162.      diffusion, big specularity, big phong factor and metalness
  163.      factor equal to 1.
  164.  
  165.      surface dielectric color transparency refraction - tran-
  166.      sparent surface with no diffusion, some specularity, large
  167.      phong factor and null metalness.
  168.  
  169.      surface glass color transparency - transparent surface with
  170.      refraction index equal to 1.52, approximately.
  171.  
  172.                          OBJECT COMMANDS
  173.  
  174.      The commands for objects are of the form
  175.           object object_data
  176.      or else with local commands that apply only to itself of the
  177.      form
  178.           object [attributes ... data] object_data.
  179.  
  180.      sphere center radius.
  181.  
  182.      box center sizes - this is an axis-aligned box.
  183.  
  184.      cube center size - again it is axis-aligned.
  185.  
  186.      cone apex base base_radius - closed cone.
  187.  
  188.      cone open apex base base_radius.
  189.  
  190.      cylinder apex base radius - closed cylinder.
  191.  
  192.      cylinder open apex base radius.
  193.  
  194.      cone truncated apex apex_radius base base_radius - closed.
  195.  
  196.      cone truncated open apex apex_radius base base_radius.
  197.  
  198.      wedge point point point depth - defined by a triangular face
  199.      and depth (face is defined counterclockwise so that depth is
  200.      measured in the opposite direction of Rigth Hand Rule thumb;
  201.      this convention also applies to other objects).
  202.  
  203.      tetra point point point point.
  204.  
  205.      prism depth number_vertices point ... point - closed prism.
  206.  
  207.      prism open depth number_vertices point ... point.
  208.  
  209.      pyramid depth number_vertices point ... point - closed
  210.      pyramid.
  211.  
  212.      pyramid open depth number_vertices point ... point.
  213.  
  214.      pyramid truncated open depth apex_scale number_vertices
  215.      point ... point - it is an open pyramid with the apex scaled
  216.      by apex_scale in relation to its base (if 0 it is an open
  217.      pyramid, if 1 it is a prism).
  218.  
  219.      disc center normal radius.
  220.  
  221.      ring center normal outer_radius inner_radius.
  222.  
  223.      patch point ... point (12) - a bicubic patch is defined by
  224.      its corners and 8 exterior points, arranged in this manner:
  225.                        11  12
  226.                      7  8  9  10
  227.                      3  4  5  6
  228.                         1  2
  229.      Normal points according to Right Hand Rule using corners 4-
  230.      5-9-8.
  231.  
  232.      patch file [point [point]] filename - a group of patches
  233.      stored in a file; first point is a translation and second is
  234.      a scale.
  235.  
  236.      polygon number_vertices point ... point - a polygon (can be
  237.      concave, but does not have holes).
  238.  
  239.      polygon file [point [point]] filename - a group of polygons
  240.      stored in a file; first point is a translation and second is
  241.      a scale.
  242.  
  243.      triangle point point point.
  244.  
  245.      quadrangle point point point point.
  246.  
  247.      triangle normal point vector point vector point vector - a
  248.      triangle with normals in its vertices.
  249.  
  250.      triangle normal file point point filename - a group of tri-
  251.      angles with normals in the vertices stored in a file; first
  252.      point is a translation and second is a scale.
  253.  
  254.      torus outer_radius section_radius start_angle end_angle
  255.      [outer_samples section_samples] - A closed torus is centered
  256.      in {0,0,0} and lies in the XZ plane. 0 degrees is in the X
  257.      direction and the angle increases counterclockwise.
  258.  
  259.      torus open outer_radius section_radius start_angle end_angle
  260.      [outer_samples section_samples] - An open torus.
  261.  
  262.      text3d file filename - a group of text primitives stored in
  263.      a file; each primitive is described by lines and arcs and is
  264.      extruded (similar to a prism, in a certain way).
  265.  
  266.      csg begin - start of a CSG primitive, ie, left component.
  267.  
  268.      csg next - right component of a CSG primitive.
  269.  
  270.      csg end - end of a CSG primitive.
  271.  
  272.      list begin - start of a list primitive (no nesting allowed).
  273.  
  274.      list end - end of a list primitive.
  275.  
  276.                          TRANSFORMATION COMMANDS
  277.  
  278.      A transformation may be defined globaly or inside a block,
  279.      and it is post-concatenated with previous transformations.
  280.      If inside a block, when the block is terminated the
  281.      transformations defined inside it are removed. Also, when a
  282.      transformation is an attribute of an object or texture it
  283.      only exists for that entity.
  284.  
  285.      transform none - removes all transformations.
  286.  
  287.      transform scale factor [factor factor].
  288.  
  289.      transform translate point.
  290.  
  291.      transform rotate x angle.
  292.  
  293.      transform rotate y angle.
  294.  
  295.      transform rotate z angle.
  296.  
  297.      transform rotate axis angle.
  298.  
  299.      transform general point point point [point].
  300.  
  301.                          TEXTURE COMMANDS
  302.  
  303.      A texture is basically a modification of the surface charac-
  304.      teristics of an object, a modification of the normal vector
  305.      in the intersection point or the modification of the inter-
  306.      section point itself. It is possible to apply transforma-
  307.      tions to textures, and even keep them independent from the
  308.      object transformations.
  309.  
  310.      texture none - remove all defined textures.
  311.  
  312.      texture scale factor [factor factor].
  313.  
  314.      texture translate point.
  315.  
  316.      texture rotate x angle.
  317.  
  318.      texture rotate y angle.
  319.  
  320.      texture rotate z angle.
  321.  
  322.      texture rotate axis angle.
  323.  
  324.      texture general point point point [point].
  325.  
  326.      texture local - generate all the transformations necessary
  327.      to access the object directly, without considering any
  328.      object transformations previously defined.
  329.  
  330.      checkers surface [transform] - a chessboard-like pattern of
  331.      the current surface and the defined surface.
  332.  
  333.      blotch scale surface [filename] [transform] - A spray-like
  334.      mixture of 2 surfaces (the current and the defined). The
  335.      scale controls the mixture. If a filename is given, it is
  336.      interpreted as a color palette, and it must contain 256 tri-
  337.      plets of RGB values in the range 0 to 255 (this format is
  338.      equal for all the textures that have a filename parameter,
  339.      except imagemap).
  340.  
  341.      bump scale [transform] - A normal-modifying texture.
  342.  
  343.      marble [filename] [transform] - A marble-like texture.
  344.  
  345.      fbm offset scale omega lambda threshold octaves [filename]
  346.      [transform] - A fractal brownian motion texture that changes
  347.      diffusion and specularity.
  348.  
  349.      fbmbump offset scale lambda octaves [transform] - a texture
  350.      that modifies the normal.
  351.  
  352.      wood color [transform] - A texture imitating wood (default
  353.      color is brown).
  354.  
  355.      round scale [transform] - strange texture that modifies dif-
  356.      fusion and specularity.
  357.  
  358.      bozo turbulence [filename] [transform].
  359.  
  360.      ripples frequency phase scale [transform] - a texture that
  361.      imitates ripples (small sinusoidal perturbations of the sur-
  362.      face).
  363.  
  364.      waves frequency phase scale [transform] - a texture like
  365.      waves (multi-interfering sinusoidal perturbations of the
  366.      surface).
  367.  
  368.      spotted [filename] [transform] - small color spots.
  369.  
  370.      dents scale [transform] - small modifications of normal that
  371.      imitate dents.
  372.  
  373.      agate [filename] [transform].
  374.  
  375.      wrinkles [transform] - a texture that modifies normal imi-
  376.      tating wrinkles.
  377.  
  378.      granite [filename] [transform].
  379.  
  380.      gradient turbulence direction [filename] [transform] - This
  381.      texture produces a variation of color following direction
  382.      given.
  383.  
  384.      imagemap turbulence mode u_axis v_axis filename [transform]
  385.      - An image-mapping texture. Mode parameter controls tiling
  386.      of texture (0-yes, nonzero-no).  The u_axis and v_axis
  387.      specify the internal texture axis from the 3D axis (1-X, 2-
  388.      Y, 3-Z).  A filename must be given, because it is the image
  389.      that will be drawn on the surface (the format of the image
  390.      is the rtrace format PIC).
  391.  
  392.      gloss scale [transform] - Glossy-like texture that changes
  393.      diffusion, specularity and phong factor.
  394.  
  395.      bump3 scale size [transform] - A normal-modifying texture.
  396.      Changes intersection point, so may produce strange results!
  397.  
  398. EXAMPLES
  399.      Here are some simple examples:
  400.  
  401.      %%%%% example 1
  402.      % light source
  403.      light point 4 3 1
  404.      % surface
  405.      surface matte red
  406.      sphere 0 0 0 1
  407.      % another surface (replaces previous)
  408.      surface plastic blue mono 0.3 0.3
  409.      sphere 3 -0.4 0.4 0.2
  410.      % another surface
  411.      surface plastic yellow mono 0.9 0.9
  412.      % transformations for next object(s)
  413.      transform rotate y rtod(atan(1))
  414.      transform translate 3 -0.4 -0.4
  415.      box 0 0 0 0.1 0.1 0.3
  416.      % remove previous transformation(s)
  417.      transform none
  418.      % another surface
  419.      surface green mono 0.8 mono 0.2 10 0.3
  420.      cone 3 0.1 0 3 -0.4 0 0.2
  421.      surface matte white
  422.      csg subtraction begin
  423.          sphere 0 0 0 1
  424.          csg next
  425.          box 0 0 0 1.1 0.4 0.4
  426.      csg end
  427.  
  428.      This example is correct, although it does not take full
  429.      usage of SCN, ie, the capability of defining locally the
  430.      attributes. It could be rewritten:
  431.  
  432.      %%%%% example 2
  433.      % light source
  434.      light point 4 3 1
  435.      % now all objects have local attributes
  436.      sphere
  437.          surface matte red
  438.          data 0 0 0 1
  439.      sphere
  440.          surface plastic blue mono 0.3 0.3
  441.          data 3 -0.4 0.4 0.2
  442.      box
  443.          surface plastic yellow mono 0.9 0.9
  444.          % local transformations
  445.          transform rotate y rtod(atan(1))
  446.          transform translate 3 -0.4 -0.4
  447.          % this object is defined in a local coords system
  448.          % the translation puts it in the right place
  449.          data 0 0 0 0.1 0.1 0.3
  450.      cone
  451.          surface green mono 0.8 mono 0.2 10 0.3
  452.          data 3 0.1 0 3 -0.4 0 0.2
  453.      csg subtraction surface matte white
  454.          data begin
  455.          sphere 0 0 0 1
  456.          csg next
  457.          box 0 0 0 1.1 0.4 0.4
  458.      csg end
  459.  
  460.      To produce an image from any of these examples, the example
  461.      should be stored in a file (suppose example.scn) and then
  462.      execute
  463.        scn2sff example.scn|rtrace w512 p2 A0.1 - example.pic
  464.      to create the image.  If the SCN file contained any cpp
  465.      preprocessor directives, then
  466.        scn2sff C example.scn|rtrace w512 p2 A0.1 - example.pic
  467.      would do.
  468.  
  469.      A complete demo example follows:
  470.      [Start]
  471.      % example to be traced with parameters like
  472.      % w512 p2 A0.1 t1 I1 - good quality
  473.      % or then
  474.      % w512 p3 A.05 t1 I1 j1 - very good quality
  475.  
  476.      %%%%% start
  477.      eye 5 2 2
  478.      fov 20
  479.      background light_sky_blue
  480.      ambient mono 0.2 % dark grey
  481.  
  482.      light point 3 5 4 white
  483.  
  484.      surface matte red % default surface
  485.  
  486.      %%%%% a simple CSG example
  487.      csg subtraction begin
  488.      % no attributes for this CSG, so it uses the attributes
  489.      % of its nodes...
  490.  
  491.        % left node
  492.        csg subtraction
  493.          % attributes of this CSG object
  494.          surface matte white
  495.          texture scale 0.2
  496.          checkers surface matte mono 0.3 translate 0.1 0.1 0.1
  497.          data begin
  498.  
  499.          box 0 0 0 1 1 1
  500.  
  501.        csg next
  502.  
  503.          box 0 0 0 1.01 0.5 0.5
  504.          list begin
  505.            % a cylinder must be enclosed in a list, because it is
  506.            % not a closed object, but 3 objects joined together
  507.            cylinder 0 1.01 0 0 -1.01 0 0.5
  508.          list end
  509.  
  510.        csg end
  511.  
  512.      csg next
  513.  
  514.        % right node
  515.        sphere 1 1 1 0.5 % default surface assumed
  516.        sphere 1 1 -1 0.5
  517.        sphere surface matte blue data 1 -1 1 0.5
  518.        sphere surface matte blue data 1 -1 -1 0.5
  519.  
  520.      csg end
  521.  
  522.      %%%%% some 3D text
  523.      text3d file surface matte yellow
  524.        data csg.t3d % data is in file
  525.  
  526.      %%%%% end
  527.      [End]
  528.  
  529.      The csg.t3d file contents could be:
  530.      [Start]
  531.      SPACING 0.1
  532.      ORIENTATION 0 0 -1 0 1 0 1 0 0
  533.      ENCODING abc.ppe
  534.      FONT zurichcg.ppf
  535.      SCALE 0.4 0.4 0.2
  536.      AT 1.25 1.5 1.6 "Antonio Costa"
  537.      FONT renfrew.ppf
  538.      SCALE 0.4 0.4 0.1
  539.      AT 1.1 -0.85 1.1 "/copyright/1992"
  540.      AT 1.1 -1.3 1.1 "INESCn"
  541.  
  542.      # there must be an empty line in the end
  543.      Description:
  544.      SPACING is letter spacing
  545.      ORIENTATION defines how the text appears
  546.       - 1st: text direction vector (left to right)
  547.       - 2nd: vertical vector
  548.       - 3rd: depth vector
  549.      ENCODING associates logical character names to glyph numbers
  550.      FONT is the file where the 2D glyphs are defined
  551.      SCALE controls scaling along ORIENTATION vectors
  552.      AT is baseline lower left position of text plus text
  553.      (quoted)
  554.      [End]
  555.  
  556. HISTORY
  557.      Copyright (C) 1991 1992 by Antonio Costa.
  558.      Permission is granted to use this file in whole or in part
  559.      for any purpose, educational, recreational or commercial,
  560.      provided that this copyright notice is retained unchanged.
  561.      This software is available to all free of charge by
  562.      anonymous FTP.
  563.  
  564.      23-Jul-92  Antonio Costa at INESC-Norte
  565.           Release 1.3.1
  566.           acc@asterix.inescn.pt acc@basinger.inescn.pt
  567.